<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Import from a binary string</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.gmp-hamdist.html">« gmp_hamdist</a></li>
      <li style="float: right;"><a href="function.gmp-init.html">gmp_init »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.gmp.html">GMP 函数</a></li>
    <li>Import from a binary string</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.gmp-import" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">gmp_import</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.6.1, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">gmp_import</span> &mdash; <span class="dc-title">Import from a binary string</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.gmp-import-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>gmp_import</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$word_size</code><span class="initializer"> = 1</span></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = GMP_MSW_FIRST | GMP_NATIVE_ENDIAN</span></span>): <span class="type"><a href="class.gmp.html" class="type GMP">GMP</a></span></div>

  <p class="para rdfs-comment">
   Import a GMP number from a binary string
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-function.gmp-import-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">data</code></dt>

     <dd>

      <p class="para">
       The binary string being imported
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">word_size</code></dt>

     <dd>

      <p class="para">
       Default value is 1. The number of bytes in each chunk of binary data. This is mainly used in conjunction with the options parameter.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">flags</code></dt>

     <dd>

      <p class="para">
       Default value is <strong><code>GMP_MSW_FIRST</code></strong> | <strong><code>GMP_NATIVE_ENDIAN</code></strong>.
      </p>
     </dd>

       
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.gmp-import-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns a GMP number.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.gmp-import-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       This function no longer returns <strong><code>false</code></strong> on failure.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.gmp-import-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3049">
    <p><strong>示例 #1 <span class="function"><strong>gmp_import()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$number&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">gmp_import</span><span style="color: #007700">(</span><span style="color: #DD0000">"\0"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">gmp_strval</span><span style="color: #007700">(</span><span style="color: #0000BB">$number</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$number&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">gmp_import</span><span style="color: #007700">(</span><span style="color: #DD0000">"\0\1\2"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">gmp_strval</span><span style="color: #007700">(</span><span style="color: #0000BB">$number</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
0
258
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.gmp-import-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.gmp-export.html" class="function" rel="rdfs-seeAlso">gmp_export()</a> - Export to a binary string</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>